var WxParse = require('../../wxParse/wxParse.js');

var app = getApp()
Page({
  data: {
    userInfo: {}
  },
  onLoad: function (e) {
    var that = this;
    if(e&&e.id){
      that.setData({
        id:e.id
      })
    }
  
    if (!app.globalData.plumSession) {
      app.plumSessionCallback = plumSession => {
        that.requestDetail();
      }
    } else {
      that.requestDetail();
    }
  },
  requestDetail: function () {
    var that = this;
    //发起请求，获取列表列表
    wx.showLoading({
      title: '加载中',
    })
    wx.request({
      url: app.globalData.requestUrl,
      data: {
        map: 'applet_help_center_detail',
        id: that.data.id
      },
      success: function (res) {
        if (res.data.ec == 200) {
          console.log(res.data.data)
          var articleInfo = res.data.data;
          that.setData({
            articleInfo: articleInfo
          })
          var article = articleInfo.content;
          // 富文本解析
          WxParse.wxParse('article', 'html', article, that, 5);
          app.setNavtitle(articleInfo.title);
        } else {
          console.log(res.data)
          app.errorTip(that, res.data.em, 2000);
          that.setData({
            articleInfo: ""
          })
        }
      },
      complete: function () {
        wx.hideLoading();
      }
    });
  },
})